<template>
  <div>
    <!-- <el-form ref="form" :model="form" label-width="110px" enctype="multipart/form-data"
      label-position="right" style="margin-top: 20px;">
      <el-row :gutter="24">
        <el-col :sm="6">
          <el-form-item label="月份" name="scoreMonth">
            <el-date-picker type="month" placeholder="选择月份" v-model="form.scoreMonth"
              value-format="yyyy-MM" format="yyyy-MM" style="width: 100%;"></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form> -->

    <div style="margin-right: 15px;margin-top: 10px;clear: both;height: 35px;">
      <!-- <el-upload class="upload-demo" style="float: right;margin-bottom: 5px;" action=""
        :http-request="handleUpload1" :show-file-list="false">
        <el-button type="warning" size="mini">导入</el-button>
        <div slot="tip" class="el-upload__tip"></div>
      </el-upload> -->
      <!-- <el-button type="primary" style="float: right;margin-right: 10px;" size="mini"
        @click="clickDlTemp">导出</el-button> -->
<!--
      <el-button type="success" style="float: right;margin-bottom: 5px;margin-right: 10px;"
        size="mini" @click="clickQuery">查询</el-button> -->
    </div>
    <div style="padding: 10px 20px;" v-if="user.roleName != 'company'">
      <div style="font-size: 18px;text-align: center;font-weight: bold;color: black;">
        资产方隐患整改情况
      </div>
      <el-table :data="tableData1" :key="key" style="width: 100%;border: solid 1px #c0c0c0;"
        row-key="index" header-row-class-name="table_header"
        :header-cell-style="{ borderColor: '#C0C0C0' }" :cell-style="{ borderColor: '#C0C0C0' }"
        border @cell-dblclick="doubleClick" id="out-table">
        <el-table-column prop="typeName" label="统计类型" align="center" min-width="160px">

        </el-table-column>
        <el-table-column prop="score1" label="Jan" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score1" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score1 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score2" label="Feb" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score2" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score2 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score3" label="Mar" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score3" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score3 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score4" label="Apr" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score4" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score4 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score5" label="May" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score5" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score5 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score6" label="Jun" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score6" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score6 }}</span>
          </template>
        </el-table-column>

        <el-table-column prop="score7" label="Jul" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score7" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score7 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score8" label="Aug" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score8" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score8 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score9" label="Sep" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score9" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score9 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score10" label="Oct" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score10" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score10 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score11" label="Nov" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score11" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score11 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score12" label="Dec" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score12" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score12 }}</span>
          </template>
        </el-table-column>

        <!-- <el-table-column label="操作" width="180" align="center">
          <template slot-scope="scope">
            <el-button size="mini" type="danger"
              @click="clickDel(scope.$index, scope.row)">删除</el-button>

          </template>
        </el-table-column> -->
      </el-table>
    </div>

    <div style="padding: 10px 20px;" >
      <div style="font-size: 18px;text-align: center;font-weight: bold;color: black;">
        企业隐患整改情况
      </div>
      <el-table :data="tableData2" :key="key" style="width: 100%;border: solid 1px #c0c0c0;"
        row-key="index" header-row-class-name="table_header"
        :header-cell-style="{ borderColor: '#C0C0C0' }" :cell-style="{ borderColor: '#C0C0C0' }"
        border @cell-dblclick="doubleClick" id="out-table">
        <el-table-column prop="typeName" label="统计类型" align="center" min-width="160px">

        </el-table-column>
        <el-table-column prop="score1" label="Jan" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score1" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score1 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score2" label="Feb" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score2" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score2 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score3" label="Mar" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score3" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score3 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score4" label="Apr" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score4" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score4 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score5" label="May" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score5" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score5 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score6" label="Jun" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score6" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score6 }}</span>
          </template>
        </el-table-column>

        <el-table-column prop="score7" label="Jul" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score7" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score7 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score8" label="Aug" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score8" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score8 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score9" label="Sep" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score9" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score9 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score10" label="Oct" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score10" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score10 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score11" label="Nov" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score11" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score11 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score12" label="Dec" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score12" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score12 }}</span>
          </template>
        </el-table-column>

        <!-- <el-table-column label="操作" width="180" align="center">
          <template slot-scope="scope">
            <el-button size="mini" type="danger"
              @click="clickDel(scope.$index, scope.row)">删除</el-button>

          </template>
        </el-table-column> -->
      </el-table>
    </div>

    <div style="padding: 10px 20px;" v-if="user.roleName != 'company'">
      <div style="font-size: 18px;text-align: center;font-weight: bold;color: black;;">
        载体隐患整改情况
      </div>
      <el-table :data="tableData3" :key="key" style="width: 100%;border: solid 1px #c0c0c0;"
        row-key="index" header-row-class-name="table_header"
        :header-cell-style="{ borderColor: '#C0C0C0' }" :cell-style="{ borderColor: '#C0C0C0' }"
        border @cell-dblclick="doubleClick" id="out-table">
        <el-table-column prop="typeName" label="统计类型" align="center" min-width="160px">

        </el-table-column>
        <el-table-column prop="score1" label="Jan" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score1" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score1 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score2" label="Feb" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score2" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score2 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score3" label="Mar" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score3" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score3 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score4" label="Apr" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score4" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score4 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score5" label="May" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score5" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score5 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score6" label="Jun" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score6" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score6 }}</span>
          </template>
        </el-table-column>

        <el-table-column prop="score7" label="Jul" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score7" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score7 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score8" label="Aug" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score8" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score8 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score9" label="Sep" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score9" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score9 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score10" label="Oct" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score10" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score10 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score11" label="Nov" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score11" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score11 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score12" label="Dec" align="center" min-width="50px">
          <template slot-scope="scope">
            <el-input v-focus v-if="scope.row[scope.column.property + 'Show']" clearable
              v-model="scope.row.score12" @keyup.enter.native="blurInput"
              @blur="onBlur(scope.row, scope.column)"></el-input>
            <span v-else>{{ scope.row.score12 }}</span>
          </template>
        </el-table-column>

        <!-- <el-table-column label="操作" width="180" align="center">
          <template slot-scope="scope">
            <el-button size="mini" type="danger"
              @click="clickDel(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column> -->
      </el-table>
    </div>

    <el-pagination background layout="prev, pager, next" :total="total_size" :page-size="100"
      :current-page="page_no">
    </el-pagination>

    <UpdateModal ref="UpdateModalRef" :clickQuery="clickQuery" :saveFun="updateCarryDanger"
      :addFun="addCarryDanger" />

    <el-dialog title="删除提示" :visible.sync="delVisible" width="30%">
      <span>确定删除吗？</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="delVisible = false">取 消</el-button>
        <el-button type="primary" @click="handleDelete">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import UpdateModal from './updateModal';
import {
  queryCarryDangerList,
  updateCarryDanger,
  addCarryDanger,
  delCarryDanger,
  getCompanyDangerStat,
  importExcel,
  exportCarryDanger,
} from '@/service/carryDanger';
import columns from './table';
import { getCurrUser } from '@/common/constants';

// import { tableMixin } from '@/mixin/table';

export default {
  components: { UpdateModal },
  // mixins: [tableMixin],

  data() {
    return {
      data: [],
      user: {},
      key: Math.random(),
      pagination: {
        showLessItems: true,
        showQuickJumper: true,
        showSizeChanger: true,
      },
      query: {},
      columns: columns,
      currItem: {},
      page_no: 0,
      page_size: 100,
      form: {},
      tableLoading: false,
      tableData1: [],
      tableData2: [],
      tableData3: [],
      total_size: 0,
      loading: false,
      updateCarryDanger,
      addCarryDanger,
      queryCarryDangerList,
      delVisible: false,
    };
  },

  methods: {
    clickShowEdit(index, record) {
      this.$refs.UpdateModalRef.openEditDialog({ ...record });
    },
    clickAdd(record) {
      this.$refs.UpdateModalRef.openAddDialog();
    },
    clickDel(index, row) {
      this.delVisible = true;
      this.currItem = { ...row };
    },
    async clickDlTemp(index, row) {
      const res = await exportCarryDanger({});
      let url = window.URL.createObjectURL(res);
      let link = document.createElement('a');
      link.style.display = 'none';
      link.href = url;

      const date = new Date();
      let dateStr =
        date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();

      link.setAttribute('download', '载体隐患-' + dateStr + '.xlsx');

      document.body.appendChild(link);

      link.click();

      window.URL.revokeObjectURL(url);
      document.body.removeChild(link);
    },
    blurInput(e){
      e.target.blur()
    },
    doubleClick(row, column) {
      // 避免点击过快导致多个输入框处于焦点状态
      row[column.property + 'Show'] = false;
      // 避免点击其他单元格导致表格刷新

      console.log('column.property', column.property);
      if (
        ![
          'score1',
          'score2',
          'score3',
          'score4',
          'score5',
          'score6',
          'score7',
          'score8',
          'score9',
          'score10',
          'score11',
          'score12',
        ].includes(column.property)
      )
        return;
      row[column.property + 'Show'] = true;
      this.key = Math.random();
      console.log('row', row);
      // this.updateTable(row);
    },
    //输入框失焦事件
    onBlur(row, column) {
      row[column.property + 'Show'] = false;
      this.updateTable(row);

      // 请求后台更改数据
    },
    async saveData(row) {
      const res = await updateCarryDanger(row);
      if (res.success) {
        this.$message.success('保存成功');
      } else {
        this.$message.error('保存失败');
      }
      this.clickQuery();
    },

    //更新表格
    updateTable(row) {
      this.saveData(row);
    },
    getFD(fileObj) {
      const formData = new FormData();
      formData.append('file', fileObj.file);
      return formData;
    },
    async handleUpload1(fileObj) {
      const fd = this.getFD(fileObj);
      let res = await importExcel(fd);
      if (res.success) {
        this.clickQuery();
      }
      return false;
    },

    async handleDelete() {
      this.delVisible = false;
      const res = await delCarryDanger({
        ...this.currItem,
      });
      if (res.success) {
        this.clickQuery();
      } else {
      }
    },
    async loadCompanyStat(){
      const res = await getCompanyDangerStat({
        ...this.form,
        page_no: this.page_no,
        page_size: this.page_size,
        compName:this.user.userId
      });
      if (res.success) {
        this.total_size = res.total;
        console.log('res.dataList',res.dataList);
        this.tableData2 = res.dataList.filter(
          (item) => item.targetName == '企业隐患'
        );
        const types = [
          '隐患数量',
          '整改完成数量',
          '整改完成率',
          '截至当月累计隐患数量',
          '截至当月累计整改数量',
          '累计完成率',
        ];
        let tData = [];
        for (let type of types) {
          for (let d of this.tableData2) {
            if (d.typeName == type) {
              if (type == '截至当月累计隐患数量') {
                tData.push({ targetName: '', typeName: '  .' });
              }
              tData.push(d);
            }
          }
        }
        this.tableData2 = tData;

      } else {
        this.total_size = 0;
        this.tableData = [];
      }

    },

    async clickQuery() {
      this.loading = true;
      if(this.user.roleName == 'company'){
        this.loadCompanyStat()
      }else{
        const res = await queryCarryDangerList({
        ...this.form,
        page_no: this.page_no,
        page_size: this.page_size,
      });
      if (res.success) {
        this.total_size = res.total;
        this.tableData1 = res.dataList.filter(
          (item) => item.targetName == '资产方隐患'
        );
        const types = [
          '隐患数量',
          '整改完成数量',
          '整改完成率',
          '截至当月累计隐患数量',
          '截至当月累计整改数量',
          '累计完成率',
        ];
        let tData = [];
        for (let type of types) {
          for (let d of this.tableData1) {
            if (d.typeName == type) {
              if (type == '截至当月累计隐患数量') {
                tData.push({ targetName: '', typeName: '  .' });
              }
              tData.push(d);
            }
          }
        }
        this.tableData1 = tData;

        this.tableData2 = res.dataList.filter(
          (item) => item.targetName == '企业隐患'
        );
        tData = [];
        for (let type of types) {
          for (let d of this.tableData2) {
            if (d.typeName == type) {
              if (type == '截至当月累计隐患数量') {
                tData.push({ targetName: '', typeName: '  .' });
              }
              tData.push(d);
            }
          }
        }
        this.tableData2 = tData;

        this.tableData3 = res.dataList.filter(
          (item) => item.targetName == '载体隐患'
        );
        tData = [];
        for (let type of types) {
          for (let d of this.tableData3) {
            if (d.typeName == type) {
              if (type == '截至当月累计隐患数量') {
                tData.push({ targetName: '', typeName: '  .' });
              }
              tData.push(d);
            }
          }
        }
        this.tableData3 = tData;
      } else {
        this.total_size = 0;
        this.tableData = [];
      }
      this.loading = false;
      }

    },

    // updateCarryDanger(){

    // }
  },
  created() {
    // const date = new Date();
    // const currMonth = date.getFullYear() + '-' + (date.getMonth() + 1);
    // this.$set(this.form, 'scoreMonth', currMonth);
    // this.form.scoreMonth = currMonth;
    // console.log('this.form.currMonth', this.form.currMonth);
  },

  mounted() {
    console.log('ff:' + this.tableData);
    console.log('ff11:' + this.clickQuery);
    this.user = getCurrUser();

    this.clickQuery();
  },
};
</script>
<style scoped>
.a {
}

/deep/ .table_header th {
  background-color: #e3e3e3 !important;
  height: 40px;
}

::v-deep .el-table .el-table__cell {
  padding: 4px 0px;
}
</style>